<template>
  <div>
    <el-card class="box-card">
    <el-form
      :inline="true"
      :model="dataForm"
      @keyup.enter.native="getExportDispatchList()"
      class="dadeFrom"
    >
    <el-select v-model="dataForm.sceneName" placeholder="场景名称" clearable style="width: 200px">
      <el-option
        v-for="option in latnIdList"
        :key="option.latnId"
        :label="option.latnName"
        :value="option.latnId"
      >
      </el-option>
    </el-select>
    <el-select v-model="dataForm.variable1" placeholder="变量1" clearable style="width: 200px">
      <el-option
        v-for="option in latnIdList"
        :key="option.latnId"
        :label="option.latnName"
        :value="option.latnId"
      >
      </el-option>
    </el-select>
    <el-select v-model="dataForm.variable2" placeholder="变量2" clearable style="width: 200px">
      <el-option
        v-for="option in latnIdList"
        :key="option.latnId"
        :label="option.latnName"
        :value="option.latnId"
      >
      </el-option>
    </el-select>
    <el-date-picker
      v-model="dataForm.timeVal"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
    <el-button @click="searchData()" type="primary">查询</el-button>
    </el-form>
    </el-card>
    <el-card class="box-card" style="margin-top: 10px;">
      <el-button type="success" size="mini" @click="handleAdd">查阅</el-button>
      <el-table
        :data="dataList"
        border
        style="width: 100%;margin-top: 20px;"
        @selection-change="handleSelectionChange"
      >
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
          type="index"
          label="序号"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="dayId"
          label="场景名称"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="变量1"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="变量2"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="创建日期"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
        >
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
        </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <Pagination
        :total="total"
        :pageNum="pageNum" 
        :pageSize="pageSize" 
        @pageChange="pageChange"
      />
    </el-card>
   <!-- 弹窗, 新增 / 修改 -->
    <el-dialog
      title="填写信息"
      :visible.sync="dialogVisible"
      width="50%"
      >
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="场景名称">
          <el-select v-model="form.sceneName" placeholder="请选择推送方式">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <div style="display: flex;">
          <el-form-item label="变量1">
            <el-select v-model="form.variable1" placeholder="请选择推送模式">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="配置API">
            <el-select v-model="form.api1" placeholder="请选择活动类型">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item label="变量2">
            <el-select v-model="form.variable2" placeholder="请选择推送模式">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="配置API">
            <el-select v-model="form.api2" placeholder="请选择活动类型">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="danger" @click="handleSave">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
        dataList: [],
        pageNum: 1,
        pageSize: 10,
        total: 0,
        latnIdList: [],
        dialogVisible: false,
        dataForm: {
          sceneName: '',
          variable1: '',
          variable2: '',
          timeVal: ''
        },
        form: {
          sceneName: '',
          variable1: '',
          api1: '',
          variable2: '',
          api2: ''
        }
      }
  },
  created() {
  },
  methods: {
    // 查阅
    handleAdd () {
      this.dialogVisible = true
      this.sceneName = ''
      this.variable1 = ''
      this.api1 = ''
      this.variable2 = ''
      this.api2 = ''
    },
    // 保存
    handleSave () {},
    // 多选
    handleSelectionChange (val) {
      console.log(val)
    },
    // 点击搜索
    searchData () {},
    // 获取表格数据
    handleDetail () {},
    // 编辑
    handleEdit () {},
    // 删除
    handleDelete () {},
    // 分页
    pageChange (page) {
      this.pageSize = page._pageSize;
      this.pageNum = page._currentPage;
      this.fetchTableList()
    }
  }
};
</script>
<style scoped>
</style>
